#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"

void solve(){
    ll N=1234567890;
    ll n,d,l=0;
    cin>>n>>d;
    N+=d;
    N*=pow(10,ceil(log10((double)n)));
    ll k=ceil((N*1.0)/(n*1.0));
    cout<<k<<'\n';
    return;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int _=1;
    cin>>_;
    while(_--){
        solve();
    }
    return 0;
}